package com.foomia.truego;

import org.json.JSONException;
import org.json.JSONObject;

import com.foomia.truego.parsers.json.AbstractParser;
import com.foomia.truego.parsers.json.Parser;
import com.foomia.truego.types.Post;
import com.foomia.truego.types.Tip;
import com.foomia.truego.types.TruegoType;

public class PostParser extends  AbstractParser<Post> {
	@Override
	public Post parse(JSONObject json) throws JSONException {
		Post obj = new Post();
		
		if (json.has("user_name")) {
			obj.setUsername(json.getString("user_name"));
		}
		
		if (json.has("user_id")) {
			obj.setUserid(json.getString("user_id"));
		}
		
		if (json.has("user_icon")) {
			obj.setUsericon(json.getString("user_icon"));
		}
		
		if (json.has("status_id")) {
			obj.setStatusid(json.getString("status_id"));
		}
		
		if (json.has("stuff_tag")) {
			obj.setStufftag(json.getString("stuff_tag"));
		}
		
		if (json.has("stuff_name")) {
			obj.setStuffname(json.getString("stuff_name"));
		}
		
		if (json.has("stuff_price")) {
			obj.setStuffprice(json.getString("stuff_price"));
		}
		
		if (json.has("stuff_desc")) {
			obj.setStuffdesc(json.getString("stuff_desc"));
		}
		
		if (json.has("small_pic")) {
			obj.setSmallpic(json.getString("small_pic"));
		}
		
		if (json.has("middle_pic")) {
			obj.setMiddlepic(json.getString("middle_pic"));
		}
		
		if (json.has("large_pic")) {
			obj.setLargepic(json.getString("large_pic"));
		}
		
		if (json.has("created_datetime")) {
			obj.setCreateddatetime(json.getString("created_datetime"));
		}
		
		return obj;
	}
	
	
}
